#!/bin/bash  
  
# 询问是否安装桌面图形化  
read -p "您是否希望安装GNOME Desktop? (yes/no): " choice  
  
# 检查用户输入  
case "$choice" in  
    yes|y|Y )  
        # 安装GNOME Desktop  
        # 注意：在CentOS 7上，您可能需要启用EPEL仓库来获取一些额外的软件包  
        # yum install epel-release  
  
        # 安装GNOME Desktop和相关软件包  
        yum groupinstall -y "GNOME Desktop"  
  
        # 检查安装是否成功  
        if [ $? -eq 0 ]; then  
            echo "GNOME Desktop 安装成功"  
            # 设置图形化模式  
            systemctl set-default graphical.target  
            echo "图形化模式已设置"  
        else  
            echo "GNOME Desktop 安装失败"  
        fi  
        ;;  
    no|n|N )  
        echo "安装取消"  
        exit 0  
        ;;  
    * )  
        echo "无效输入"  
        exit 1  
        ;;  
esac